﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StrategyPattern
{
    /// <summary>
    /// 主要是简单耦合   
    /// </summary>
    public class CashContext
    {
        CashSuper cs = null;
        public CashContext(string type) 
        {
            switch (type)
            {

                case "正常收费":
                    cs = new CashNormal();
                    break;
                case "满300返100":
                    CashRetutn crl = new CashRetutn(Convert.ToDouble("300"), Convert.ToDouble("100"));
                    cs = crl;
                    break;
                case "打8折":
                    CashRebate cr2 = new CashRebate(Convert.ToDouble("0.8"));
                    cs = cr2;
                    break;
                default:
                    break;
            }
        }

        public double GetResult(double money) 
        {
            return cs.acceptCash(money);
        }

    }
}
